﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using Sahit.iSoilHotel.Domain.MainBoundedContext.Tavern.Aggregates.RoomAgg;

namespace Sahit.iSoilHotel.Infrastructure.DataAccess.MainBoundedContext.Tavern.Mapping.Rooms
{
    public class RoomMap : 
        EntityTypeConfiguration<Room>
    {
        public RoomMap()
        {
            this.ToTable("Room");

            this.HasKey(r=> r.ID);
            this.Property(r => r.Number).HasMaxLength(50);

            this.Ignore(r => r.Status);
            this.Property(r => r.StatusID);

            this.HasRequired(r => r.RoomType).WithMany().HasForeignKey(r=>r.RoomTypeID);
            this.HasRequired(r => r.RoomBuilding).WithMany().HasForeignKey(r => r.BuildingID);

            this.HasMany(r => r.RoomSettings).WithMany().Map(m => m.ToTable("Room_RoomSettings_Mapping"));
        }
    }
}
